// 引入mock 生成数据
import Mock from 'mockjs'
var data = Mock.mock({
    'items|2-10': [{
        'title': '@ctitle',
        'name': '@cname',
        'id|100000+1': 100000,
        'data': randomDate,
        'apply': '@natural(0, 10000)',
        'image': '@image(100x100, @color, #fff, chair)',
        'subject': randomCourse,
    }],
})
// 创建接口
Mock.mock('/audition', 'get', data.items)
// 生成随机日期
function randomDate() {
    const date = new Date(Mock.Random.date('yyyy-MM-dd'))
    const days = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
    const classes = ['七年级', '八年级', '九年级', '高一', '高二', '高三']
    const randomClass = Mock.Random.pick(classes)
    const day = days[date.getDay()]
    const hours = Mock.Random.natural(0, 23)
    const minutes = Mock.Random.natural(0, 59)
    return `${date.getMonth() + 1}月${date.getDate()}日${day}${hours}:${minutes < 10 ? '0' + minutes : minutes}开始  ${randomClass}`
}
// 生成随机课程
function randomCourse() {
    const courses = ['语文', '数学', '英语', '物理', '化学', '生物', '政治', '历史', '地理']
    return Mock.Random.pick(courses)
}